import axios from 'axios';

export default {
	state:{
		loadingToastMsg:'',
		loadingToast:false,
		// new module
		toastEnabled:false,
		toastMessage:'',
		icon:'check',
	},
	actions:{
		getWechatMenu({state},params){
			return new Promise((resolve,reject)=>{
				const url = 'http://s1.fsthz.com:8080' + '/core/wx/menu/get';
				const config = {url,method:'post',headers:{'Content-Type':'application/json'}};
				axios(config)
					.then(res=>res.errCode?reject(res):resolve(res.data))
					.catch(error=>reject(error))
			})
		},
		updateWechatMenu({state},params){
			return new Promise((resolve,reject)=>{
				const url = 'http://s1.fsthz.com:8080' + '/core/wx/menu/create';
				const config = {url,method:'post',headers:{'Content-Type':'application/json'},data:params.data};
				axios(config)
					.then(res=>res.data.errCode?reject(res):resolve(res.data))
					.catch(error=>reject(error))
			})
		},
	},
};
